<?php
/**
 * Created by PhpStorm.
 * User: lx
 * Date: 2020/1/6
 * Time: 10:28
 */

namespace app\api\controller;


use app\Validate\ConfigValidate;
use data\service\Platform;

class Config
{
    /**
     * 获取所有位置
     *
     * @return string
     * @throws \Exception
     * @author dzl
     */
        public function adList(){
            $page_index = request()->post("pageIndex", 1);
            $page_size = request()->post('page_size', PAGESIZE);
            $platform = new Platform();
            $condition['type'] = 3;
            $condition['is_use'] = 1;
            $list = $platform->getPlatformAdvPositionList($page_index, $page_size, $condition,'');

            return return_json_data($list);
        }


    /**
     * 获取当前页的广告
     *
     * @return string
     * @throws \Exception
     * @author dzl
     */
        public function adLocalList(ConfigValidate $configValidate){
            $ap_keyword = $configValidate->request->post('ap_keyword');
            $platform = new Platform();
            if(!empty($ap_keyword)){
                $condition['ap_keyword'] = $ap_keyword;
            }
            $condition['type'] = 3;
            $condition['is_use'] = 1;
            $position_info = $platform->getPlatformAdvPositionOne( $condition,'');
            $list['position_info'] = $position_info;
            $ap_id = $position_info['ap_id'];
            $where['ap_id'] = $ap_id;
            $list['ad_list'] = $platform->getLocalAdList($where,'');

            return return_json_data($list);
        }

}